﻿using Apple.DAL;
using Apple.Helper;
using Apple.Model.Entity;
using HZY.Framework.DependencyInjection;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apple.BLL
{
    public class UserManager : IScopedSelfDependency
    {
        private readonly UserService _userService;

        public UserManager(UserService userService)
        {
            _userService = userService;
        }

        public async Task<BaseResult<UserEntity>> LoginAsync(UserLoginDto request)
        {
            var entity = request.Adapt<UserEntity>();

            var res = await _userService.LoginAsync(entity);

            if (res.Status == SystemEnums.Result.Fail)
            {
                return new BaseResult<UserEntity>() { Status = SystemEnums.Result.Fail, Msg = res.Msg };
            }

            return res;

        }
    }
}
